package com.example.springDataJPA.hibernateAssociations;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;

/**
 * <pre>
 * 功能描述：在现实开发中，@ManyToMany注解用的比较少,一般都会使用成对的@ManyToOne 和 @OneToMany代替，因为我们的中间表可能还有一些约定的公共字段，如ID,update_time,create_time等其他字段
 * </pre>
 *
 * @author: 李明杰
 * @date: 2023/6/8 20:15
 */
@Entity
@Table(name = "jpa_student_teacher")
@Data
@AllArgsConstructor
@NoArgsConstructor
public class StudentTeacher {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    @ManyToOne
    private Student student;

    @ManyToOne
    private Teacher teacher;

    @Override
    public String toString() {
        return "StudentTeacher{" +
                "teacher=" + teacher +
                '}';
    }
}
